//
//  MainScreenCtrl.m
//  MK
//
//  Created by duong2179 on 8/11/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "MainScreenCtrl.h"

@implementation MainScreenCtrl

@synthesize homeBtn, SocialBtn, MusicBtn, newsBtn, linksBtn, infoBtn, mainView, myView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        homeViewController = nil;
        socialViewController = nil;
        newsViewController = nil;
        musicViewController = nil;
        linksViewController = nil;
        infoViewController = nil;
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor blackColor];
    [homeBtn setImage:[UIImage imageNamed:@"home.png"] forState:UIControlStateNormal];
    
    [SocialBtn setImage:[UIImage imageNamed:@"social_select.png"] forState:UIControlStateNormal];
    [SocialBtn setImage:[UIImage imageNamed:@"social.png"] forState:UIControlStateHighlighted];
    
    [MusicBtn setImage:[UIImage imageNamed:@"music_select.png"] forState:UIControlStateNormal];
    [MusicBtn setImage:[UIImage imageNamed:@"music.png"] forState:UIControlStateHighlighted];
    
    [newsBtn setImage:[UIImage imageNamed:@"news_select.png"] forState:UIControlStateNormal];
    [newsBtn setImage:[UIImage imageNamed:@"news.png"] forState:UIControlStateHighlighted];
    
    [linksBtn setImage:[UIImage imageNamed:@"link_select.png"] forState:UIControlStateNormal];
    [linksBtn setImage:[UIImage imageNamed:@"links.png"] forState:UIControlStateHighlighted];
    
    [infoBtn setImage:[UIImage imageNamed:@"info_select.png"] forState:UIControlStateNormal];
    [infoBtn setImage:[UIImage imageNamed:@"info.png"] forState:UIControlStateHighlighted];
    // Do any additional setup after loading the view from its nib.
    
    HomeViewController *ctrl = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
    myView = ctrl.view;
    [myView setFrame:[mainView frame]];
    [self.mainView addSubview:myView];
    [ctrl release];
}

- (void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBarHidden = YES;}

- (void) viewWillDisappear:(BOOL)animated
{
    self.navigationController.navigationBarHidden = NO;
    [super viewWillDisappear:animated];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(IBAction) onHomeClick: (id) sender
{
    
}

-(IBAction) onSocialClick: (id) sender 
{
    SocialViewController *ctrl = [[SocialViewController alloc] initWithNibName:@"SocialViewController" bundle:nil];
    [self.navigationController pushViewController:ctrl animated:YES];
    [ctrl release];
}

-(IBAction) onNewsClick: (id) sender
{

    NewsViewController *ctrl = [[NewsViewController alloc] initWithNibName:@"NewsViewController" bundle:nil];
    [self.navigationController pushViewController:ctrl animated:YES];
    [ctrl release];
}

-(IBAction) onMusicClick: (id) sender
{
    MusicViewController *ctrl = [[MusicViewController alloc] initWithNibName:@"MusicViewController" bundle:nil];
    [self.navigationController pushViewController:ctrl animated:YES];
    [ctrl release];
}

-(IBAction) onLinksClick: (id) sender
{
    LinksViewController *ctrl = [[LinksViewController alloc] initWithNibName:@"LinksViewController" bundle:nil];
    [self.navigationController pushViewController:ctrl animated:YES];
    [ctrl release];
}

-(IBAction) onInfoClick: (id) sender
{
    InfoViewController *ctrl = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:nil];
    [self.navigationController pushViewController:ctrl animated:YES];
    [ctrl release];
}

- (void) dealloc
{
    [homeBtn release];
    [linksBtn release];
    [infoBtn release];
    [SocialBtn release];
    [newsBtn release];
    [MusicBtn release];
    
    [mainView release];
    [myView release];
    [super dealloc];
}

@end
